﻿using DDDSystem.Application.Contracts;
using DDDSystem.Domain.Shared;
using Microsoft.AspNetCore.Mvc;

namespace DDDSystem.HttpApi.Host.Controllers;

/// <summary>
/// 基础字典服务
/// </summary>
[Route("psi/[controller]/v1")]
[ApiController]
public class BasicDictionaryController : ControllerBase
{
    private IBasicDictionaryService _basicDictionaryService;

    public BasicDictionaryController(IBasicDictionaryService basicDictionaryService)
    {
        _basicDictionaryService = basicDictionaryService;
    }

    /// <summary>
    /// 根据类别获取基础字典列表
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    [HttpGet]
    [Route("{type}")]
    public async Task<IActionResult> Get(BasicDictionaryType type)
    {
        var items = await Task.Factory.StartNew(() =>
        {
            return _basicDictionaryService.Get(type);
        });

        return Ok(items);
    }
}


